*--------------------------------------------------------------; * Estimate of the population mean or total for a single-stage ; * cluster sample, in which clusters are selected with proba- ; * bility proportional to size of cluster, with replacement. ; *--------------------------------------------------------------; %macro est_cl1p(sample=,setup=,npop=,n=,cluster=,mi=,response=, ybar=,totals=,phat=,param=,m=,rep=); %if %length(&cluster) = 0 %then %let cluster = %str(cluster); %if %length(&sample) = 0 %then %let sample = %str(sample); %if %length(&rep) > 0 %then %let strep = %str(&cluster &rep); %else %let strep = %str(&cluster); proc sort data = &sample; by &strep; %if %length(&response) > 0 %then %do; %let strng = %str(Response Variable = &response); proc means data = &sample noprint; by &strep; var &response; output out = temp_ mean = ybari_ ; %end; %if %length(&ybar) > 0 %then %do; %let strng = %str(Response Variable (Means) = &ybar); data temp_; set &sample; ybari_ = &ybar; %end; %if %length(&phat) > 0 %then %do; %let strng = %str(Response Variable (Proportions) = &phat); data temp_; set &sample; ybari_ = &phat; %end; %if %length(&totals) > 0 %then %do; %let strng = %str(Response Variable (Totals) = &totals); data temp_; set &sample; ybari_ = &totals/&mi; %end; proc means data = temp_ noprint; var ybari_; output out = new_ mean=ybar_ var=s2_ n=n_; data est_; %if %length(&setup) > 0 %then %do; merge &setup new_; %end; %else %do; set new_; %end; mu_hat_ = ybar_; var_mu_ = s2_/n_; std_mu_ = sqrt(var_mu_); bnd_mu_ = 2*std_mu_; %if %length(&m) > 0 %then %do; tau_hat_ = &m*ybar_; std_tau_ = &m*std_mu_; bnd_tau_ = &m*bnd_mu_; %end; %if %index(%upcase(¶m),MEAN) > 0 %then %do; proc print data = est_ noobs split = '*'; title1 'Estimate of the Population Mean'; title2 'Single-Stage Cluster Design'; title3 'Cluster Selected Proportional to Size'; title4 "&strng"; label mu_hat_ = 'Estimate'; label std_mu_ = 'Standard*Error'; label bnd_mu_ = 'Bound'; label s2_ = 's^2'; var mu_hat_ std_mu_ bnd_mu_ s2_; %end; %if %index(%upcase(¶m),PROP) > 0 %then %do; proc print data = est_ noobs split = '*'; title1 'Estimate of the Population Proportion'; title2 'Single-Stage Cluster Design'; title3 'Cluster Selected Proportional to Size'; title4 "&strng"; label mu_hat_ = 'Estimate'; label std_mu_ = 'Standard*Error'; label bnd_mu_ = 'Bound'; label s2_ = 's^2'; var mu_hat_ std_mu_ bnd_mu_ s2_; %end; %if %index(%upcase(¶m),TOTAL) > 0 %then %do; proc print data = est_ noobs split = '*'; title1 'Estimate of the Population Total'; title2 'Single-Stage Cluster Design'; title3 'Cluster Selected Proportional to Size'; title4 "&strng"; label tau_hat_ = 'Estimate'; label std_tau_ = 'Standard*Error'; label bnd_tau_ = 'Bound'; label s2_ = 's^2'; var tau_hat_ std_tau_ bnd_tau_ s2_; %end; run; title; %mend est_cl1p;